﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace com.dz.ht.ui
{
    public partial class FrmBook : Form
    {
        public FrmBook()
        {
            InitializeComponent();
        }

        private string m_site_id_list = string.Empty;
        public string SiteIdList
        {
            get { return m_site_id_list; }
            set { m_site_id_list = value; }
        }

        private string m_collect_type_list = string.Empty;
        public string CollectTypeList
        {
            get { return m_collect_type_list; }
            set { m_collect_type_list = value; }
        }

        private string m_url = string.Empty;
        public string Url
        {
            get { return m_url; }
            set { m_url = value; }
        }
        private bool m_in_db = false;
        public bool InDB
        {
            get { return m_in_db; }
            set { m_in_db = value; }
        }

        private void chkUrl_CheckedChanged(object sender, EventArgs e)
        {
            if (chkUrl.Checked)
            {
                chkBookListUrl.Checked = false;
              
                txtUrl.Enabled = true;

            }
            else
            {
                chkBookListUrl.Checked = true;
              
                txtUrl.Enabled = false;

            }
        }

        private void btnStart_Click(object sender, EventArgs e)
        {
            foreach (System.Windows.Forms.Control control in this.grpCom.Controls)
            {
                if (control is System.Windows.Forms.CheckBox)
                {
                    CheckBox chk = (CheckBox)control;
                    if (chk.Checked)
                    {
                        m_site_id_list = m_site_id_list + chk.Text.ToString() + ",";
                    }
                }
            }
            if (string.IsNullOrEmpty(m_site_id_list))
            {
                MessageBox.Show("请选择组件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            //更新列表
            if (chkBookListUrl.Checked)
            {
                m_collect_type_list += "1,";
            }
            //最近更新
            if (chkLastUpdate.Checked)
            {
                m_collect_type_list += "2,";
            }
           
            if (chkUrl.Checked)
            {
                m_collect_type_list += "0,";
                Url = txtUrl.Text.ToString();
            }
            if (chkDefault.Checked)
            {
                m_collect_type_list += "4,";
            }
            InDB = chkRuKu.Checked;
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
    }
}
